#include "GroupAdapter_2_2.h"

namespace jm4bbx {

#ifdef BOBOX_VERSION_2_2

	GroupAdapter_2_2::GroupAdapter_2_2(groupImpl* g, boxImpl* box, groupType gType) 
		: group_(g)
		, box_(box)
		, groupType_(gType)
		, pos_(0) { }


	size_t GroupAdapter_2_2::getReadBegin() const {
		return 0;
	}

	size_t GroupAdapter_2_2::getReadPosition() const {
		return pos_;
	}

	void GroupAdapter_2_2::moveReadPosition(int val /*= 1*/) {
		pos_ += val;
	}

	size_t GroupAdapter_2_2::getReadEnd() const {
		return group_->size();
	}

	void GroupAdapter_2_2::relocate(size_t from, size_t to) {
		if (from != 0) {
			box_->relocate(groupType_, from);
		}
		group_->resize(to - from);
	}


	void GroupAdapter_2_2::allocate(size_t size) {
		box_->allocate(groupType_, size);
		// Nesmie sa volat hned resize pretoze sa pamat alokuje oneskorene a
		// doslo by teda k pokusu nastavit velkost pre nealokovany priestor.
		// Nastastie alokacia v tejto verzii resizne velkost sama.
		//resize(size);
	}

	void GroupAdapter_2_2::resize(size_t size) {
		group_->resize(size);
	}


	bool GroupAdapter_2_2::isPoisoned() const {
		return group_->is_poisoned();
	}

	size_t GroupAdapter_2_2::getColumnCount() const {
		return group_->get_columns_count();
	}

#endif

} // namespace jm4bbx
